/*
*	ID : pallab81
* 	PROG : 4495
* 	LANG : C++
* 	2011-10-07-17.26.12 Friday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
int N,S,W;
vector< VI > pages;
int dp[1010];

inline int go(int cur_line) {

    if( cur_line > N ) {
        return 0;
    }
    if( dp[cur_line]!=-1 ) {
        return dp[cur_line];
    }
    int best = (int)1023456789;
    set< int > foot_notes;
    for(int line=1; line<=S; ++line) {
        int new_line = cur_line+(line-1);
        if( new_line > N )break;
        VI vi = pages[ new_line ]; // current page er jonno foot notes lagbe
        int sz = SZ(vi);
        fo(i,sz) {
            foot_notes.insert( vi[i] );
        }
        int sz_ = SZ(foot_notes);
        if( sz_+line <=S ) {
            int var = sz_ + go( cur_line+line );
            best = min(best ,var );
        } else {
            break;
        }
    }
    dp[ cur_line ] = best;
    return best;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in", "rt", stdin);
#endif
    int cases = 1;
    int K=1;
    for ( CI(cases) ; cases; --cases,++K) {
        scanf("%d %d %d",&N,&S,&W);
        pages.assign(N+5, VI() );
        fo(i,W) {
            int x;
            CI(x);
            fo(j,x) {
                int y;
                CI(y);
                pages[y].pb(i+1);
            }
        }
        SET(dp,-1);
        int var = go(1);
        var = var < (int)1023456789 ? var : (int)-1 ;
        printf("Case %d: %d\n",K,var );
    }

    return 0;
}
